package com.jye.cloud.user.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {


//    @Bean
//    public Docket docket2(Environment environment){
//        return new Docket(DocumentationType.SWAGGER_2).groupName("A");
//    }

    @Bean
    public Docket docket(Environment environment) {
        //开发版的话会显示。
//        Profiles profiles = Profiles.of("dev");
//
//        boolean flag = environment.acceptsProfiles(profiles);
//
//        System.out.println(flag);
        boolean flag = true;
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("ojj")
                .apiInfo(apiInfo())
                .enable(flag)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.jye.cloud.user"))
                .build();
    }

    public ApiInfo apiInfo() {
        Contact contact = new Contact("欧建杰", "http://47.106.229.162:8080/dubbo", "2233017662@qq.com");
        return new ApiInfo
                (
                        "欧建杰的Swagger",
                        "wdnmd",
                        "ojj",
                        "http://47.106.229.162:8099/swagger-ui.html",
                        contact,
                        "Apache 2.0",
                        "http://www.apache.org/licenses/LICENSE-2.0",
                        new ArrayList()
                );
    }


}
